package com.xx.controller;

import com.github.pagehelper.PageInfo;
import com.xx.domain.Product;
import com.xx.service.ShowProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @Author : 徐闯 ssm_admin
 * @Date : 2021-05-13 11:05:07
 * @Description : 展示旅游产品的Controller
 **/
@Controller
@ResponseBody
public class ShowProductController {
    @Autowired
    private ShowProductService showProductService;
    @RequestMapping("/queryProduct")
    public PageInfo queryProduct(@RequestParam(name = "num",required = true,defaultValue = "1") int num,
                                 @RequestParam(name="size",required = true,defaultValue = "10") int size) throws InterruptedException {
        Thread.sleep(1000);
        return  showProductService.showALlProduct(num,size);
    }
    @RequestMapping("/queryOne")
    public Product querOneProduct(int id){
        return showProductService.showOneProduct(id);
    }
    @RequestMapping("/searchProducts")
    public List<Product> queryProducts(String content){
        System.out.println(content);
        return showProductService.showProducts(content);
    }
}
